﻿using System; 
using System.Data;
using System.Collections.Generic; 
using JOIN.Rights.Model;

/*------------------------------------------------------------------------
   苏州捷安信息科技有限公司 版权所有			
   文件名: TU_OrgArea.cs
   作 者 : 席吉波
   日 期 : 2012/10/12 16:10:47
   备 注 : 当您对本文件更改时请写明修改人、修改日期以及是由
  ------------------------------------------------------------------------
*/

namespace JOIN.Rights.BLL
{
	 	//TU_OrgArea
		public partial class OrgAreaBLL:BLLBase
	{
		//private readonly ITU_OrgArea dal=DataAccess.CreateTU_OrgArea();
		public OrgAreaBLL(OrgAreaInfo entity)
			:base(entity)
		{
		
		}
		
		#region  Method
		/*
		/// <summary>
		/// 是否存在该记录
		/// </summary>
		public bool Exists()
		{
			return dal.Exists();
		}

		/// <summary>
		/// 增加一条数据
		/// </summary>
		public int  Add(JOIN.Rights.Model.TU_OrgArea model)
		{
			return dal.Add(model);
						
		}

		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update(JOIN.Rights.Model.TU_OrgArea model)
		{
			return dal.Update(model);
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete(int ID)
		{
			
			return dal.Delete(ID);
		}
				/// <summary>
		/// 批量删除一批数据
		/// </summary>
		public bool DeleteList(string IDlist )
		{
			return dal.DeleteList(IDlist );
		}
		
		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public JOIN.Rights.Model.TU_OrgArea GetModel(int ID)
		{
			
			return dal.GetModel(ID);
		}

		/// <summary>
		/// 得到一个对象实体，从缓存中
		/// </summary>
		public JOIN.Rights.Model.TU_OrgArea GetModelByCache(int ID)
		{
			
			string CacheKey = "TU_OrgAreaModel-" + ID;
			object objModel = Maticsoft.Common.DataCache.GetCache(CacheKey);
			if (objModel == null)
			{
				try
				{
					objModel = dal.GetModel(ID);
					if (objModel != null)
					{
						int ModelCache = Maticsoft.Common.ConfigHelper.GetConfigInt("ModelCache");
						Maticsoft.Common.DataCache.SetCache(CacheKey, objModel, DateTime.Now.AddMinutes(ModelCache), TimeSpan.Zero);
					}
				}
				catch{}
			}
			return (JOIN.Rights.Model.TU_OrgArea)objModel;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			return dal.GetList(strWhere);
		}
		/// <summary>
		/// 获得前几行数据
		/// </summary>
		public DataSet GetList(int Top,string strWhere,string filedOrder)
		{
			return dal.GetList(Top,strWhere,filedOrder);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<JOIN.Rights.Model.TU_OrgArea> GetModelList(string strWhere)
		{
			DataSet ds = dal.GetList(strWhere);
			return DataTableToList(ds.Tables[0]);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<JOIN.Rights.Model.TU_OrgArea> DataTableToList(DataTable dt)
		{
			List<JOIN.Rights.Model.TU_OrgArea> modelList = new List<JOIN.Rights.Model.TU_OrgArea>();
			int rowsCount = dt.Rows.Count;
			if (rowsCount > 0)
			{
				JOIN.Rights.Model.TU_OrgArea model;
				for (int n = 0; n < rowsCount; n++)
				{
					model = new JOIN.Rights.Model.TU_OrgArea();					
									if(dt.Rows[n]["ID"].ToString()!="")
				{
					model.ID=int.Parse(dt.Rows[n]["ID"].ToString());
				}
																												model.OrgID= dt.Rows[n]["OrgID"].ToString();
																												model.AreaID= dt.Rows[n]["AreaID"].ToString();
																						
				
					modelList.Add(model);
				}
			}
			return modelList;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetAllList()
		{
			return GetList("");
		}
		//*/
#endregion
   
	}
}